package Operate;

import Contact.Contacts;
import Contact.Contactsllist;

import java.util.Scanner;

public class Change implements Operation {
    @Override
    public void Operate(Contactsllist contactsllist) {
        int s=contactsllist.getS();
        System.out.println("输入你想要改变信息的姓名；");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();
        for (int i = 0; i < s; i++) {
            String name1=contactsllist.Show(i).name;
            if (name.equals(name1)) {
                System.out.println("找到了！");
                System.out.println(contactsllist.Show(i));
                System.out.println("请选择你要修改的信息：");
                System.out.println("*****************");
                System.out.println("0.名字");
                System.out.println("1.年龄");
                System.out.println("2.emil");
                System.out.println("*****************");
                Scanner scanner1=new Scanner(System.in);
                int choice=scanner1.nextInt();
                switch (choice){
                    case 0:
                        System.out.println("请输入修改名：");
                        String name2=scanner1.nextLine();
                        contactsllist.Show(i).name=name2;
                        break;
                    case 1:
                        System.out.println("请输入修改年龄：");
                        int age1=scanner1.nextInt();
                        contactsllist.Show(i).age=age1;
                        break;
                    case 2:
                        System.out.println("请输入修改emil：");
                        String emil=scanner1.nextLine();
                        contactsllist.Show(i).emil=emil;
                        break;
                }
            } else {
                System.out.println("没找到！");
                break;
            }
        }
    }
}
